<?php
    session_start();
    if($_SESSION['uid']==""||$_SESSION['level']!=3){
		header("Location: ../exit.php");
		exit();
    }
    include('/tool/submitValidate.php');
	include('/tool/pdo.php');
	include('/bll/DormCenterBLL.php');
	include('/class/dorm-center.class.php');
    
    $action = isset($_POST['action']) ? $_POST['action'] : 0;
    $data = isset($_POST['data']) ? $_POST['data'] : null;
    
    switch((int)$action){
        //添加辅导员管理的专业和年级
        case 1:
            $instructorInfo=json_decode($data);;
            if($data!=null){
                $dormCenterBLL=new DormCenterBLL();
                $message=$dormCenterBLL->addInstructorMajorGrade($instructorInfo);
            }
            break;
        //删除辅导员管理的专业和年级
        case 2:
            $instructorInfoList=json_decode($data);;
            if($data!=null){
                $dormCenterBLL=new DormCenterBLL();
                $message=$dormCenterBLL->deleteInstructorMajorGrade($instructorInfoList);
            }
            
            break;
        //修改辅导员管理的专业和年级
        case 3:
            $instructorInfo=json_decode($data);;
            $dormCenterBLL=new DormCenterBLL();
            if($data!=null){
                $message=$dormCenterBLL->editInstructorMajorGrade($instructorInfo);
            }
            break;
        default:break;
    }

    echo json_encode($message,JSON_UNESCAPED_UNICODE);
?>